package com.example.jiwhsgs;

import android.graphics.drawable.Drawable;
import android.os.Bundle;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.method.LinkMovementMethod;
import android.text.style.ImageSpan;
import android.text.style.URLSpan;
import android.widget.TextView;

public class Jiwhactivity extends AppCompatActivity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jiwh);

        TextView textView = findViewById(R.id.jiwhView);

        // 创建 SpannableString
        String text = "软件开源地址：\nhttps://gitee.com/green-lattice-is-lifelike/jiwh-sgs";
        SpannableString spannableString = new SpannableString(text);

        // 设置超链接
        int startIndex = text.indexOf("https://gitee.com/green-lattice-is-lifelike/jiwh-sgs");
        int endIndex = startIndex + "https://gitee.com/green-lattice-is-lifelike/jiwh-sgs".length();
        spannableString.setSpan(new URLSpan("https://gitee.com/green-lattice-is-lifelike/jiwh-sgs"), startIndex, endIndex, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

        textView.setText(spannableString);
        textView.setMovementMethod(LinkMovementMethod.getInstance());
    }
}
